/**
 * 发布新版时可以不把此文件包含
 * @author: welling
 */

Weifox.debug={
	splice:function(){
		var x=[0,1,2,3,4,5];
		x.splice(1,2);
		//alert(x.toString());
		var x=new String('\u7f3a\u5c11photo\u53c2\u6570');
		alert(x);
	},
	testProcess:function(){
		var data={x:123456};
		Weifox.apps.tencent.processOAuth(data);
		this.showObj(data);
	},
	setPref:function(){

		var p = Weifox.browser.pref;
		var x = window.prompt('input:');
		alert(x);
		p.setCharPref('test', unescape(encodeURIComponent(x+" vb -")));

	},
	getPref:function(){
		
		var v=decodeURIComponent(escape(Weifox.browser.pref.getCharPref('test')));
		alert(v);
		document.getElementById('weifox-title-user').childNodes[1].value=v;
		return v;
	},
	showObj:function(obj){
		var str='';
		var c=0;
		for(var i in obj){
			
			if(c==5){
				c=0;
				str+='\n';
			}c++;
			if(obj[i] instanceof Function )
			str+=i+'=func  ';
			else 
			str+=i+'='+obj[i]+';';
		}
		alert("Show:"+str);
		return str;
	},
	oauthTest: function(){

		var o=new Weifox.net.OAuth('1920019471','33a1a9ca5d594db252df8b92af94f07a',
								   '','http://api.t.sina.com.cn/oauth/request_token',null,null,{type:'header'});
		var oauth_token='';
		var oauth_token_secret='';
		o.send(function(text){
				var a=text.split('&');
				oauth_token=a[0].split('=')[1];
				oauth_token_secret=a[1].split('=')[1];
				alert(text+'\n'+oauth_token+"\n"+oauth_token_secret);
				Weifox.debug.oauth_token=oauth_token;
				Weifox.debug.oauth_token_secret=oauth_token_secret;
				Weifox.browser.openLink('http://api.t.sina.com.cn/oauth/authorize?oauth_token='
					+oauth_token+'&callback=oob',true);
		});
    },
	oauth:function(){
		var pin=window.prompt('input PIN code:');
		var o=new Weifox.net.OAuth('1920019471','33a1a9ca5d594db252df8b92af94f07a',
								   this.oauth_token_secret,'http://api.t.sina.com.cn/oauth/access_token'
								   ,
								   [['oauth_verifier',pin],
								   ['oauth_token',this.oauth_token]]
								   );
						   
		o.send(function(text){
			var a=text.split('&');
			oauth_token=a[0].split('=')[1];
			oauth_token_secret=a[1].split('=')[1];
			Weifox.debug.oauth_token=oauth_token;
			Weifox.debug.oauth_token_secret=oauth_token_secret;
		});

	},
	say:function(){
		//oauth_token=a8e5b8806efe1075fcbf0a50d9934579&oauth_token_secret=45f4d392f989fa2c34ff44bb225184c2&user_id=1665025612
		var say= encodeURIComponent( window.prompt('you say:'));
		var o=new Weifox.net.OAuth('1920019471','33a1a9ca5d594db252df8b92af94f07a',
								   this.oauth_token_secret,'http://api.t.sina.com.cn/statuses/update.json'
								   ,
								   [
								   ['oauth_token',this.oauth_token]],[['status',say]]
								   );
						   
		o.send(function(text){
			alert(text);
		});		
	},
	testExtend:function(){
		var base={
			name:'base',
			shout:function(){
				alert('base shout'+this.name);
			}
		}
		var child=Weifox.extend(base,{
			name:'child',
			say:function(){
				alert('child say...'+this.name);
			}
		});
		child.shout();
		child.say();
	}


}
